<template>
	<view>
		<view class="u-p-30" style="height: calc(800rpx - 60px);overflow-y: scroll;">
			<view class="u-p-b-30 u-p-t-30 u-flex u-row-between" v-for="(item,index) in addressList" :key="index" style="border-bottom: 1px solid #f2f2f2;" @click="chooseAddress(item)">
				<view>
					<view class="u-p-b-16">
						<u-tag mode="dark" text="默认" size="mini" type="warning" v-if="item.default"></u-tag>
						<text class="u-p-l-10">{{item.areaPath}}</text>
					</view>
					<view class="u-font-34 u-f-w u-p-b-16">{{item.detailAddress}}</view>
					<view class="u-flex u-p-b-16">
						<view class="u-p-r-30 u-font-26">{{item.consigneeName}}</view>
						<view class="u-font-26">{{item.consigneeMobile}}</view>
					</view>
				</view>
				<view class="u-p-r-30">
					<u-icon name="edit-pen" @click="edit(item)"></u-icon>
				</view>
			</view>
		</view>
		<view class="u-p-20" style="position: fixed;bottom: 0;left: 0;right: 0;">
			<u-button type="warning" shape="circle" :ripple="true" style="width: 80%;" @click="addAddress">
				<u-icon name="plus"></u-icon>
				<text class="u-p-l-10">新建收货地址</text>
			</u-button>
		</view>
	</view>
</template>

<script>
	export default{
		name:'myaddress',
		props:{
			addressList:{
				type:Array,
				default:[]
			}
		},
		methods:{
			addAddress(){
				uni.navigateTo({
					url:'/pages/mallDetails/addAddress'
				})
			},
			edit(item){
				uni.navigateTo({
					url:`/pages/mallDetails/addAddress?option=${JSON.stringify(item)}`
				})
			},
			chooseAddress(item){
				this.$emit('comfirmAddress',JSON.stringify(item),false);
			}
		}
	}
</script>
